import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart';
import 'package:trollee/app/core/ext/widget_extension.dart';
import 'package:trollee/app/core/utils/utils.dart';
import 'package:trollee/app/core/values/values.dart';
import 'package:trollee/app/modules/home/home/controller.dart';

class HomePage extends StatelessWidget {
  HomePage({Key? key}) : super(key: key);

  final controller = Get.put(HomeController());
  final states = Get.find<HomeController>().states;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        padding: EdgeInsets.only(
          bottom: AppDimens.bbhSafe,
          top: AppDimens.sbhSafe,
          left: AppDimens.dp24,
          right: AppDimens.dp24,
        ),
        child: Column(
          children: [
            AppGaps.vGap20,
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                SvgPicture.asset(
                  AppImages.trollee_logo_svg_while,
                  color: AppColors.font_color_black,
                  width: AppDimens.dp140,
                ),
                SvgPicture.asset(
                  AppImages.exit,
                  width: AppDimens.dp24,
                  height: AppDimens.dp24,
                ).clickOnce(UserManager.logout),
              ],
            ),
            AppGaps.vGap26,
            Container(
              alignment: Alignment.centerLeft,
              child: Text(
                'flutter测试',
                style: AppTextStyles.text_22_bold_black,
              ),
            ),
            GridView(
              shrinkWrap: true,
              padding: EdgeInsets.only(
                top: AppDimens.dp14,
                bottom: AppDimens.dp16,
              ),
              physics: const NeverScrollableScrollPhysics(),
              gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                crossAxisCount: 2,
                crossAxisSpacing: AppDimens.dp12,
                mainAxisSpacing: AppDimens.dp12,
                // mainAxisExtent: AppDimens.dp112,
                childAspectRatio: 1.34
              ),
             children: [
               Card(
                 shape: AppRadii.roundedRectangleBorderAll_16,
                 elevation: 8,
                 shadowColor: Colors.black38,
                 child: Stack(
                   children: [
                     Positioned(
                         top: AppDimens.dp12,
                         left: AppDimens.dp12,
                         child: Container(
                           constraints: BoxConstraints(
                               maxWidth: AppDimens.dp112
                           ),
                           child: Text(
                             '图片裁剪',
                             style: AppTextStyles.text_16_bold_grey,
                           ),
                         )),
                     Positioned(
                       bottom: AppDimens.dp20,
                       right: AppDimens.dp20,
                       child: SvgPicture.asset(AppImages.shopping_cart_monitoring),
                     )
                   ],
                 ),
               ).clickOnce(controller.goPush),
               Card(
                 shape: AppRadii.roundedRectangleBorderAll_16,
                 elevation: 8,
                 shadowColor: Colors.black38,
                 child: Stack(
                   children: [
                     Positioned(
                         top: AppDimens.dp12,
                         left: AppDimens.dp12,
                         child: Container(
                           constraints: BoxConstraints(
                               maxWidth: AppDimens.dp112
                           ),
                           child: Text(
                             '环保资讯',
                             style: AppTextStyles.text_16_bold_grey,
                           ),
                         )),
                     Positioned(
                       bottom: AppDimens.dp20,
                       right: AppDimens.dp20,
                       child: SvgPicture.asset(AppImages.daily_board),
                     )
                   ],
                 ),
               ).clickOnce(controller.goNews),

             ],
            ),

          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: controller.goProfile,
        backgroundColor: AppColors.primary_color,
        child: const Icon(Icons.person,color: Colors.white,),
      ),
    );
  }
}
